<?php
require_once BaseUtil::getModulePath("base") . '/models/BaseDao.php';

class CategoryProductDao extends BaseDao{

    protected $_name;

    public function  _setup() {
        $this->_name = $this->prefix() . "category_products";
        parent::_setup();
    }

    public function insertCategoryProduct($data){
        return $this->insertData($data);
    }

    public function getByProductId($productId){
        $select = $this->db_r->select();
        $select->from($this->_name,"*");
        $select->where('product_id = ?', $productId);
        $select->where('is_delete = 0');
        $sql = $select->__toString();
        $result = $this->db_r->fetchAll($sql);
        return $result;
    }

    public function deleteByProductId($productId){
        $isDel = array("is_delete"=>1);
        $where = $this->db_w->quoteInto('product_id = ?', $productId);
        $this->updateData($isDel,$where);
    }

}